package com.xmy.cultivate.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.OrderApply;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xmy.cultivate.entity.OrderDetail;
import com.xmy.cultivate.entity.OrderDisDetail;
import com.xmy.cultivate.entity.views.ResTransaction;
import com.xmy.cultivate.excel.ReturnPremiumDailySheet;
import com.xmy.cultivate.respons.OrderApplyMoreRs;
import com.xmy.cultivate.util.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

import java.math.BigDecimal;
import java.text.ParseException;
import java.time.LocalDate;
import java.util.List;
import java.util.Locale;
import java.util.Map;

/**
 * <p>
 * 订单报名信息 服务类
 * </p>
 *
 * @author min
 * @since 2022-07-28
 */
public interface IOrderApplyService extends IService<OrderApply> {

    public abstract boolean saveTo(OrderApply orderApply) throws ParseException;

    boolean saveToMore(OrderApplyMoreRs orderApplyMoreRs) throws ParseException;

    public abstract boolean updateDate(OrderApply orderApply);

    public abstract boolean transferSchoolSave(OrderApply orderApply) throws ParseException;

    public abstract Result batchTransferSchoolSave(OrderApply orderApply) throws ParseException;

    public abstract boolean transferSubjectSave(OrderApply orderApply) throws ParseException;

    public abstract boolean transferStudentSave(OrderApply orderApply) throws ParseException;

    public abstract IPage<OrderApply> findAll(IPage<?> page, Wrapper wrapper);

    OrderApply getOneForId(Long id);

    public abstract OrderApply getPrintData(Long orderId);

    public abstract List<Map<String,Object>> orderArrears(Wrapper wrapper);

    /**
     * 收支明细
     * @param page
     * @param wrapper
     * @return
     */
    public abstract IPage<OrderApply> expensesAndReceipts(IPage<?> page, Wrapper wrapper);

    public abstract IPage<ResTransaction> transaction(IPage<?> page, Wrapper wrapper);

    public abstract IPage<OrderApply> affirmIncome(IPage<?> page,Wrapper wrapper);

    /**
     * 确认到帐
     * @param id
     * @param adminId 登陆人id
     * @param isSuper 是否超级管理员
     * @return
     */
    public abstract boolean confirmArrive(Long id,Long adminId,Integer isSuper);



    public abstract boolean financeConfirm(Long id,Long adminId,Integer isSuper);

    public abstract boolean cancelConfirm(Long id,Long adminId,Integer isSuper);

    /**
     * 订单作废
     * @param id
     * @param adminId 登陆人id
     * @param isSuper 是否超级管理员
     * @return
     */
    public abstract boolean invalidate(Long id,Long adminId,Integer isSuper);

    @Transactional
    boolean invalidateDis(Long disOrderId, Long adminId, Integer isSuper);

    public abstract boolean addDiscount(OrderDetail orderDetail);

    public abstract boolean orderHouseChange(Long orderId,Integer diffCount);

    public abstract Long getApplyCount(String subjectsId,String studentId);

    Long getApplyCountForIsNew(String subjectsId, String studentId);

    /**
     *
     * @param yearPart
     * @param quarterNum
     * @param schoolId
     * @param studentId
     * @param subjectsId
     * @param orderDetailId
     * @param newOutPrice
     * @return
     */
    public abstract boolean abnormalPriceDispose(Integer yearPart, Integer quarterNum, Long schoolId, Long studentId, Long subjectsId, Long orderDetailId, BigDecimal newOutPrice);

    /**
     * 退费日报表
     *
     * @return
     */
    public abstract IPage<ReturnPremiumDailySheet> getReturnPremiumDailySheet(IPage<?> page, String orderType, String startDate, String endDate, String schoolIdList, String subjectsId, String yearClassId, String isPrint, String studentName, String status,String teacherId);

    /**
     * 退费日报表总金额
     *
     * @return
     */
    public abstract BigDecimal getReturnPremiumPrice(String orderType,String startDate,String endDate,String schoolIdList,String subjectsId,String yearClassId,String isPrint, String studentName, String status,String teacherId);

    @Transactional
    boolean addOrderDisDetaill(List<Long> studentList,Long orderId, List<OrderDisDetail> orderDisDetailList, BigDecimal disPrice, LocalDate discountsDate, Long createdId);

    Integer getNotAffirmCount(Integer yearPart,
                              Integer quarterNum,
                              Long schoolId,
                              Long studentId,
                              String subjectsId
    );

    String getNotAffirmStudentName(Integer yearPart,
                                   Integer quarterNum,
                                   Long schoolId,
                                   String studentId,
                                   String subjectsId);

    String getNotAffirmStudentNameForGradeId(Integer yearPart,
                                             Integer quarterNum,
                                             Long schoolId,
                                             String subjectsId,
                                             Long gradeId);

    public abstract OrderApply getOrderApplySum(Wrapper wrapper);

}
